package com.tanhua.server.controller;

import com.tanhua.domain.vo.AcceptVo;
import com.tanhua.server.service.AcceptService;
import com.tanhua.server.service.SendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.text.ParseException;


/**
 * @author xie
 * @date 2021/8/22
 */
@RestController
@RequestMapping("/peachblossom")
public class SendAcceptVoiceController {
    //发送语音业务层处理
    @Autowired
    private SendService sendService;
    //接收语音业务层处理
    @Autowired
    private AcceptService acceptService;

    /**
     * 发送语音
     */
    @PostMapping
    public ResponseEntity sendListen(MultipartFile soundFile) throws IOException, ParseException {
        sendService.sendListen(soundFile);
        //不用返回信息
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语音（学生实战）
     */
    @GetMapping
    public ResponseEntity acceptVoice(){
        AcceptVo acceptVo = acceptService.acceptVoice();
        //返回匹配的用户基本信息
        return ResponseEntity.ok(acceptVo);
    }







}
